<template>

  <div>
    <el-row class="params">
      <label class="row-lable">商品编号:</label>
      <el-input style="width:160px" v-model="tradeCode"></el-input>
      <el-button type="primary" @click="jump(1)">搜索</el-button>
      <el-button type="primary" style="float: right;margin-right: 30px" @click="exportBtn">导出</el-button>
    </el-row>

    <el-table :data="listData" border highlight-current-row stripe style="width: 100%;margin-top: 20px">
      <el-table-column prop="tradeCode" label="订单号"></el-table-column>
      <el-table-column prop="payTime" label="下单时间"></el-table-column>
      <el-table-column prop="sendTime" label="发货时间"></el-table-column>
      <el-table-column label="买家信息">
        <template slot-scope="scope">
          <template>id:{{scope.row.buyerId}}</template>
          <br>
          <template>{{scope.row.buyer}}</template>
        </template>
      </el-table-column>
      <el-table-column prop="itemCode" label="商品编号"></el-table-column>
      <el-table-column label="下单商品信息">
        <template slot-scope="scope">
          <img :src="scope.row.imgUrl" style="max-height: 60px;max-width: 60px">
          <br>
          <template>{{scope.row.title}}</template>
        </template>
      </el-table-column>
      <el-table-column label="实付金额">
        <template slot-scope="scope">
          <template>{{scope.row.payMoney}}</template>
          <br>
          <template>(含运费：{{scope.row.postFee}})</template>
        </template>
      </el-table-column>
      <el-table-column label="规格">
        <template slot-scope="scope">
          <template>{{scope.row.sku}}；</template>
          <template>数量{{scope.row.num}}</template>
        </template>
      </el-table-column>
      <el-table-column label="收货信息">
        <template slot-scope="scope">
          <template>姓名:{{scope.row.receiveName}}</template>
          <br>
          <template>电话:{{scope.row.receiveTelephone}}</template>
          <br>
          <template>地址:{{scope.row.provName}}{{scope.row.cityName}}{{scope.row.areaName}}{{scope.row.receiveDetail}}</template>
        </template>
      </el-table-column>
      <el-table-column label="物流">
        <template slot-scope="scope">
          <template>物流单号：{{scope.row.postCode}}</template>
          <br>
          <template>物流公司：{{scope.row.postCompany}}</template>
        </template>
      </el-table-column>
      <el-table-column label="备注">
        <template slot-scope="scope">
          <template>{{scope.row.remark}}</template>
          <el-button type="text" @click="remarkModBtn(scope.row)">备注</el-button>
        </template>
      </el-table-column>
    </el-table>

    <el-dialog type="text" :modal-append-to-body="false" :visible.sync="remarkShow" width="30%">
      <el-form>
        <el-form-item label="备注">
          <el-input v-model="remark"></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
         <el-button @click="remarkShow = false">取 消</el-button>
         <el-button type="primary" @click="modRemarkOK">确 定</el-button>
       </span>
    </el-dialog>

    <el-pagination
      background
      @current-change="jump"
      layout="total, prev, pager, next, jumper"
      :pageSize=15
      :total="total">
    </el-pagination>

  </div>

</template>

<script>
  import {ajax, allOrderList, remarkOrder} from "../../data/service";

  export default {
    name: "mallOrderAll",
    data() {
      return {
        tradeCode:'',
        listData:[],
        page:1,
        total:0,
        remarkShow:false,
        remark:'',
        advertId:''
      }
    },
    mixins: [ajax],
    created() {
      this.getList();
    },
    methods: {
      getList() {
        this.doajax(allOrderList, {page: this.page, tradeCode: this.tradeCode}, (resp) => {
          this.listData = resp.data;
          this.total = resp.total;
        })
      },

      remarkModBtn(row){
        this.tradeCode=row.tradeCode;
        this.remark = row.remark;
        this.remarkShow=true;
      },

      modRemarkOK(){
        this.doajax(remarkOrder,{tradeCode:this.tradeCode,remark:this.remark},(resp)=>{
          this.remark=resp.remark;
          this.remarkShow=false;
          this.getList();
        })
      },

      exportBtn(){
        window.location.href='/adminjson/exportTradeList.json';
      },

      jump(val) {
        this.page = val;
        this.getList();
      },
    }
  }
</script>

<style scoped>

</style>
